package com.yugao.fintech.antelope.pay.payment.controller;

import com.yugao.fintech.antelope.base.security.annotation.Anonymous;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@Slf4j
@RestController
@RequestMapping("/mock")
public class PayMockController {
    /**
     * 用于mock微信/支付授权, 假如你用的是其他人的微信支付凭证, 回调域名必须是其设置的回调域名, 所以这里mock,
     * 返回参数中的code为mock123
     */
    @Anonymous
    @GetMapping("/oauth2/authorize")
    public void oauth2Authorize(@RequestParam("redirect_uri") String redirectUri, HttpServletResponse response) throws Exception {
        log.info("执行授权服务, redirectUri: {}", redirectUri);
        response.sendRedirect(redirectUri + "&code=mock123");
    }
}
